package com.dog.basics.api.controller.common;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.api.common.ArticleFormDto;
import com.dog.basics.bean.vo.api.common.ApiArticleVo;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.security.annotation.Inner;
import com.dog.basics.service.common.IDogComArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;


/**
 * <p>
 * CMS文章表 前端控制器
 * </p>
 *
 * @author guonh
 * @since 2020-05-20
 */
@RestController
@RequestMapping("/api/article")
@Api(value = "CMS文章模块", tags = SwaggerConstants.API_ALL)
@AllArgsConstructor
@ApiIgnore
public class DogComArticleController {

    private final IDogComArticleService iDogComArticleService;

    /**
     * @Description: 分页cms文章列表
     * @Param:
     * @return:
     * @Author: zhangmr
     * @Date:
     */
    @Inner
    @ApiOperation(value = "分页cms文章列表", notes = "分页cms文章列表", tags = SwaggerConstants.API_TZWZ)
    @GetMapping("/page")
    public R<IPage<ApiArticleVo>> page(PageParam page, ArticleFormDto obj) {
        IPage<ApiArticleVo> list = iDogComArticleService.getPageListApi(page, obj);
        return R.ok(list);
    }

    /**
     * @Description: 增加cms文章点击量或分享数
     * @Param:
     * @return: Boolean
     * @Author: zhangrm
     * @Date: 2020/05/22  0027
     */
    @ApiOperation(value = "增加cms文章点击量或分享数", notes = "增加cms文章点击量或分享数", tags = SwaggerConstants.API_TZWZ)
    @ApiImplicitParams({
            @ApiImplicitParam(name ="flag"  , value ="操作类型：0 增加点击量 ，1 增加分享数",dataType = "int",required = true ),
            @ApiImplicitParam(name ="articleId"  , value ="文章id",dataType = "Long",required = true ),
    })
    @PutMapping("/addedit")
    @ApiIgnore
    public R<Boolean> addedit( Integer flag ,Long articleId) {
        return R.ok(iDogComArticleService.addedit(flag,articleId));
    }




}
